//
//  Color.h
//  Prism
//
//  Created by Bas du Pre on 25-05-11.
//  Copyright 2011 UU. All rights reserved.
//

#pragma once

#include "../global.h"
#include "../Events.h"

namespace Prism {
namespace Graphics {
    
    class Color : public PObject {
    public:
        Color();
        Color(PInt red, PInt green, PInt blue, PInt alpha = 255);
        Color(const Color & color);
        
        virtual ~Color();
        
        void copy(const Color & color);
        
        PInt red();
        void setRed(PInt red);
        PInt green();
        void setGreen(PInt green);
        PInt blue();
        void setBlue(PInt blue);
        PInt alpha();
        void setAlpha(PInt alpha);
        void setRGB(PInt red, PInt green, PInt blue, PInt alpha = 255);
        
        PInt hue();
        void setHue(PInt hue);
        PInt saturation();
        void setSaturation(PInt saturation);
        PInt value();
        void setValue(PInt value);
        void setHSV(PInt hue, PInt saturation, PInt value, PInt alpha = 255);
        
        Color & operator =(const Color& color);
        bool operator !=(const Color& color) const;
        bool operator ==(const Color& color) const;
		bool operator<(Color const&) const;
		bool operator>(Color const&) const;
		bool operator<=(Color const&) const;
		bool operator>=(Color const&) const;
        
        PInt compareTo(Color const&) const;
        
        Event<EventArgs*> onChange;
        
        virtual String toString();
        
    private:
        PInt _red, _green, _blue, _alpha;
        bool _noChangeEvent;
        
        struct RGB {
            PInt red;
            PInt green;
            PInt blue;
        };
        struct HSV {
            PInt hue;
            PInt saturation;
            PInt value;
        };       
        RGB hsvToRgb(PInt hue, PInt saturation, PInt value);
        HSV rgbToHsv(PInt red, PInt green, PInt blue);
                
    public:
        static const Color
            AliceBlue            ,
            AntiqueWhite         ,
            Aqua                 ,
            Aquamarine           , 
            Azure                ,
            
            Beige                ,
            Bisque               ,
            Black                ,
            BlanchedAlmond       ,
            Blue                 ,
            BlueViolet           ,
            Brown                ,
            Burlywood            ,
            
            CadetBlue            ,
            Chartreuse           ,
            Chocolate            ,
            Coral                ,
            CornflowerBlue       ,
            Cornsilk             ,
            Crimson              ,
            Cyan                 ,
            
            DarkBlue             ,
            DarkCyan             ,
            DarkGoldenRod        , 
            DarkGray             ,
            DarkGreen            ,
            DarkKhaki            ,
            DarkMagenta          ,
            DarkOliveGreen       , 
            DarkOrange           , 
            DarkOrchid           ,
            DarkRed              ,
            DarkSalmon           ,
            DarkSeaGreen         ,
            DarkSlateBlue        ,
            DarkSlateGray        ,
            DarkTurquoise        ,
            DarkViolet           ,
            DeepPink             ,
            DeepSkyBlue          ,
            DimGray              ,
            DodgerBlue           ,
            
            FireBrick            ,
            FloralWhite          ,
            ForestGreen          ,
            Fuchsia              ,
            
            Gainsboro            ,
            GhostWhite           ,
            Gold                 ,
            GoldenRod            ,
            Gray                 ,
            Green                ,
            GreenYellow          ,
            
            HoneyDew             ,
            HotPink              ,
            
            IndianRed            ,
            Indigo               ,
            Ivory                ,
            
            Khaki                ,
            
            Lavender             ,
            LavenderBlush        ,
            Lawngreen            ,
            LemonChiffon         ,
            LightBlue            ,
            LightCoral           ,
            LightCyan            ,
            LightGoldenRodYellow ,
            LightGreen           ,
            LightGray            ,
            LightPink            ,
            LightSalmon          ,
            LightSeaGreen        ,
            LightSkyBlue         ,
            LightSlateGray       ,
            LightSteelBlue       ,
            LightYellow          ,
            Lime                 ,
            LimeGreen            ,
            Linen                ,
            
            Magenta              ,
            Maroon               ,
            MediumAquamarine     ,
            MediumBlue           ,
            MediumOrchid         ,
            MediumPurple         ,
            MediumSeaGreen       ,
            MediumSlateBlue      ,
            MediumSpringGreen    ,
            MediumTurquoise      ,
            MediumVioletRed      ,
            MidnightBlue         ,
            MintCream            ,
            MistyRose            ,
            Moccasin             ,
            
            NavajoWhite          ,
            Navy                 ,
            Navyblue             ,
            
            OldLace              ,
            Olive                ,
            OliveDrab            ,
            Orange               ,
            OrangeRed            ,
            Orchid               ,
            
            PaleGoldenRod        ,
            PaleGreen            ,
            PaleTurquoise        ,
            PaleVioletRed        ,
            PapayaWhip           ,
            PeachPuff            ,
            Peru                 ,
            Pink                 ,
            Plum                 ,
            PowderBlue           ,
            Purple               ,
            
            Red                  ,
            RosyBrown            ,
            RoyalBlue            ,
            
            SaddleBrown          ,
            Salmon               ,
            SandyBrown           ,
            SeaGreen             ,
            SeaShell             ,
            Sienna               ,
            Silver               ,
            SkyBlue              ,
            SlateBlue            ,
            SlateGray            ,
            Snow                 ,
            SpringGreen          ,
            SteelBlue            ,
            
            Tan                  ,
            Teal                 ,
            Thistle              ,
            Tomato               ,
            Turquoise            ,
            Transparent          ,
            
            Violet               ,
            
            Wheat                ,
            White                ,
            WhiteSmoke           ,
            
            Yellow               ,
            YellowGreen          ,
            
            // Gray shades
            Gray0				 , // Black
            Gray10				 ,
            Gray20				 ,
            Gray30				 ,
            Gray40				 ,
            Gray50				 ,
            Gray60				 ,
            Gray70				 ,
            Gray80				 ,
            Gray90				 ,
            Gray100				 ; // White
    };
}
}